package cn.lovecyy.mockjson.core.type;

import cn.hutool.core.util.StrUtil;
import cn.lovecyy.mockjson.core.domain.TypeConfig;
import cn.lovecyy.mockjson.core.gen.MockRandomUtils;

/**
 * EnumTypeMocker
 *
 * @author Yakir
 */
public class EnumTypeMocker implements TypeMocker {

	@Override
	public String getType() {
		return "enum";
	}

	@Override
	public Object mock(TypeConfig config) {
		String param = config.getParam();
		String mainParam = config.getMainParam();

		String[] enums = StrUtil.splitToArray(mainParam, ",");
		return MockRandomUtils.randomFromEnum(enums);
	}

}
